@extends('users.app')
@section('title', '用户登录日志')

@section('content')
<div class="row">
    <div class="col-12 col-xl-10 m-b-10">
    <div class="card">
        <div class="card-header border-bottom">
            <h4 class="card-title">用户登录日志</h4>
        </div>
        <div class="card-body">
            <div class="row col-10">
              <form class="col-12 col-md-5 pl-0" action="{{ route('members.login_logs') }}" method="GET">
              <div class="form-group">
                <div class="input-group">
                  <input class="form-control" type="text" name="name" value="{{ old('name', Request::input('name') ?: '')}}" placeholder="输入用户名">
                  <input class="form-control" type="text" name="ip" value="{{ old('ip', Request::input('ip') ?: '')}}" placeholder="输入IP地址">
                  <div class="input-group-append">
                    <button class="btn btn-info" type="submit">搜索</button>
                  </div>
                </div>
              </div>
            </form>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered mb-0">
                    <thead>
                        <tr>
                            <th>用户名</th>
                            <th>IP地址</th>
                            <th>注册时间</th>
                            <th>登录时间</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($logs as $log)
                        <tr>
                            <td scope="row">{{ $log->user->name }}</td>
                            <td>
                              <a href="{{ route('members.login_logs', ['ip' => $log->ip])}}">{{$log->ip}}</a>
                            </td>
                            <td>{{ $log->user->created_at->diffForHumans() }}</td>
                            <td>{{ $log->created_at->diffForHumans() }}</td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
                <div class="mt-2">
                  {!! $logs->appends(Request::except('page'))->render() !!}
                </div>
            </div>
        </div>
      </div>
    </div>
</div>
@stop
